﻿using System;

namespace LiveNet.Authentication
{
    public sealed class DomainAuthenticationResponse
    {
        private readonly string m_ownerHandle;
        private readonly string m_domainAuthToken;
        private readonly DomainAuthenticationResponseCode m_ResponseCode;

        internal DomainAuthenticationResponse(DomainAuthenticationResponseCode responseCode)
        {
            m_ResponseCode = responseCode;
        }

        internal DomainAuthenticationResponse(string ownerHandle, string domainAuthToken, DomainAuthenticationResponseCode responseCode)
        {
            if (string.IsNullOrEmpty(ownerHandle))
            {
                throw new ArgumentNullException("ownerHandle");
            }

            if (string.IsNullOrEmpty(domainAuthToken))
            {
                throw new ArgumentNullException("domainAuthToken");
            }

            m_ownerHandle = ownerHandle;
            m_domainAuthToken = domainAuthToken;
            m_ResponseCode = responseCode;
        }

        public string OwnerHandle
        {
            get { return m_ownerHandle; }
        }

        public string DomainAuthToken
        {
            get { return m_domainAuthToken; }
        }

        public DomainAuthenticationResponseCode ResponseCode
        {
            get { return m_ResponseCode; }
        }

        public bool Success
        {
            get
            {
                return m_ResponseCode == DomainAuthenticationResponseCode.RequestApproved ? true : false;
            }
        }
    }
}